package main

import (
	"dogapm"
	"net/http"
	"ordersvc/api"
	"ordersvc/grpcclient"
	"proto"
)

func main() {

	// 初始化db， httpserver， grpcclient
	dogapm.Infra.NewInfra(
		dogapm.WithMySql("root:zzzfff0613@tcp(127.0.0.1:3306)/ordersvc"),
		dogapm.InfraEnableAPM("127.0.0.1:54317"),
	)

	//  grpcclient 初始化
	grpcclient.SkuClient = proto.NewSkuServiceClient(dogapm.NewGrpcClient(":8081"))
	grpcclient.UserClient = proto.NewUserServiceClient(dogapm.NewGrpcClient(":8082"))

	httpserver := dogapm.NewHttpServer(":8079")
	httpserver.HandleFunc("/test", func(writer http.ResponseWriter, request *http.Request) {
		_, _ = writer.Write([]byte("OK"))
		return
	})
	httpserver.HandleFunc("/order/add", api.Order.Add)
	dogapm.EndPoint.Start()
}
